/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.team1160.breakaway.ballControl;

import com.team1160.breakaway.api.Constants;
import com.team1160.breakaway.api.Piston;
import edu.wpi.first.wpilibj.AnalogChannel;

/**
 *
 * @author FireBird Robotics
 */
public class Kicker
{
    //private static fields
    ////////////////////////////////////////////////////////////////////////////
    protected AnalogChannel potentiometer;
    protected boolean isRetracted;
    protected Piston piston;

    //constructor
    ////////////////////////////////////////////////////////////////////////////
    public Kicker ()
    {
        init();
    }

    protected void init()
    {

        potentiometer = new AnalogChannel(Constants.C_POTENTIOMETER);

        //TODO
        //Build solenoids
        //Build piston
    }

    //methods
    ////////////////////////////////////////////////////////////////////////////
    /**
     * This method fires and retracts the Kicker
     */
    public void shoot()
    {
        fire();

        //TODO - perform wait?

        retract();


    }
    
    /**
     * Fires the kicker
     */
    public void fire() throws IllegalStateException
    {
        if (!isRetracted())
            throw new IllegalStateException("Cannot fire if not retracted");
        
        try {



            //set false once retraction is complete
            isRetracted = false;

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Retracts the kicker.
     */
    public void retract()
    {
        //already retracted?
        if (isRetracted())
            return;
        
        try {
            //TODO: retract kicker

            //set true once retraction is complete
            isRetracted = true;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public boolean isRetracted()
    {
        return this.isRetracted;
    }

    /**
     * Gets the angle of the kicker 0-360
     * @return the angle from 0-360
     */
    public int getAngle()
    {
        return 0;
      
    }
}
